<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>假日优惠图片详情</title>
    <#include "/view/admin/head.html"/>

    <style type="text/css">
        .list-path{
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;

        }
        .table-class{
            width:80%;
            text-align: center;
            border:1px solid #afd9ee;
            margin:0 auto;
            margin-top: 50px;
        }
        table th{
            width:20%;
            background-color: #d9edf7;
            text-align: right;
        }
        table td{
            width:20%;
            text-align: left;
        }
        .go-back{
            float:right;
            margin-right: 30px;

        }
    </style>

<script type="text/javascript">
function firstFileImg() {
		//input
		var docObj = document.getElementById("firstFile");
		//img
		var imgObjPreview = document.getElementById("firstImg");
		//div
		var divs = document.getElementById("localImag");
		if (docObj.files && docObj.files[0]) {
			//火狐下，直接设img属性
			imgObjPreview.style.width = '242px';
			imgObjPreview.style.height = '170px';
			//imgObjPreview.src = docObj.files[0].getAsDataURL();
			//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
			imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
		} else {
			//IE下，使用滤镜
			docObj.select();
			var imgSrc = document.selection.createRange().text;
			var localImagId = document.getElementById("localImag");
			//必须设置初始大小
			localImagId.style.width = "242px";
			localImagId.style.height = "170px";
			//图片异常的捕捉，防止用户修改后缀来伪造图片
			try {
				localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
				localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
			} catch(e) {
				alert("您上传的图片格式不正确，请重新选择!");
				return false;
			}
			
			imgObjPreview.style.display = 'none';
			
			document.selection.empty();
		}
		return true;
	}  

function secondFileImg() {
	//input
	var docObj = document.getElementById("secondFile");
	//img
	var imgObjPreview = document.getElementById("secondImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  

function thirdFileImg() {
	//input
	var docObj = document.getElementById("thirdFile");
	//img
	var imgObjPreview = document.getElementById("thirdImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  


</script>    
    
</head>
<body>

<div class="list-path" > <span style="margin-left: 50px;"><span class="glyphicon glyphicon-home"></span> 假日优惠图片详情</span></div>
    <div style="float:right;margin-right: 40px;"><a class="btn btn-info" href="${base}/discount/czjdiscountList.do">返回上一级</a></div>
</div>


<div class="table-class">       
      <#if  message?? &&  message =="1" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>发布成功</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="0" >
        <div class="alert alert-error" style="background-color: write;color: red;">           
           <font size="5"><strong>取消发布</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="2" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>保存成功</strong></font>
        </div>
     </#if>     
      
    <table class="table table-bordered">
        <thead>

        </thead>
        <tbody>
          <form  action="${base}/discount/czjdiscountSave.do?discountId=${czjdiscount.discountId!}" method="post" enctype="multipart/form-data"   id="myform" >
               <tr>
                <th>是否发布：</th>
                <td>
                   <#if  czjdiscount.ext1?? && czjdiscount.ext1 =="1">
                   <span class="label label-success">是</span>
                   <#else>
                   <span class="label label-default">否</span>
                   </#if>                                                 
                </td>
                <th>图片顺序：</th>
                <td> 
                  ${czjdiscount.imgOrder!}                                                                     
                </td>
              </tr>        
             <tr>
                <th>图片跳转地址：</th>
                <td>${czjdiscount.imgUrl!}   </td>
<!--                 <th>图片里面文字：</th>
                <td><input type="text" name="remark"value="${czjdiscount.remark!}">   </td> -->             
                <th><!-- 是否为集群车宝服务链接： --></th>
                <td>
                   <select hidden="hidden" name="ext2">
                     <option value="0"  <#if czjdiscount.ext2?? && czjdiscount.ext2="1" > selected="selected" </#if>>否</option>
                     <option value="1"  <#if czjdiscount.ext2?? && czjdiscount.ext2="1" > selected="selected" </#if>  >是</option>
                   </select>                
                </td>              
              </tr>
              <tr>
              <input style="display:none"  type="file" name="first" id="firstFile" onchange="firstFileImg();">  
<!--                 <th>上传假日优惠图片：</th>
                <td><input type="file" name="first" id="firstFile" onchange="firstFileImg();">                  
                <input  type="hidden" name="imgFirst"  value="${czjdiscount.imgPath!}"/>                
                </td> -->
<!--                 <th>是否为集群车宝服务链接：</th>
                <td>
                   <select  name="ext2">
                     <option value="0"  <#if czjdiscount.ext2?? && czjdiscount.ext2="1" > selected="selected" </#if>>否</option>
                     <option value="1"  <#if czjdiscount.ext2?? && czjdiscount.ext2="1" > selected="selected" </#if>  >是</option>
                   </select>                
                </td> -->
              </tr>           
<!--               <tr>
                <th >假日优惠图片：</th>
                <td ><img src="${base}${czjdiscount.imgPath!}" height="140px;" id="firstImg"></td>
                <th ></th>
                <td ></td>
              </tr>  -->
              

              

     </form>   


               
        </tbody>
    </table>

</div>

<script type="text/javascript">
   
   //不发布
  function notRelease(){
	  location.href="${base}/discount/czjdiscountSaveExt1.do?discountId=${czjdiscount.discountId!}&ext1=0";
  }

  //发布
  function release(){
	  location.href="${base}/discount/czjdiscountSaveExt1.do?discountId=${czjdiscount.discountId!}&ext1=1";
  }

  //提交图片
  function submitVoteOrder(){
	  
	  var imgOrder = $("#imgOrder").val();
	  
	  if(imgOrder == ""){
      	alert("图片顺序不能为空");
    	return false;
	  }
	  
	  if(!isInteger(imgOrder)){
	      	alert("图片顺序只能是正整数");
	    	return false;
	  }	
	  if(imgOrder<=0){
	      	alert("图片顺序只能是正整数");
	    	return false;
	  }	 
	  if(isNaN(imgOrder)){
	      	alert("图片顺序只能是数字");
	    	return false;
		  }	  
	  	        	
	         document.getElementById("myform").submit(); 

	  	  	  	  	  	  
	 
  }
  
  
  function weather(){
	  
	    $.ajax({  
	        type : "get",  //提交方式  
	        url : "http://v.juhe.cn/weather/index",//路径  
	        async: false,
	        data : "cityname=%E5%B9%BF%E5%B7%9E&dtype=&format=&key=2c5e51150c7bca1d83ba8dc0e21b5209",//数据，这里使用的是Json格式进行传输      
	        dataType: "json",
	        success : function(result) {//返回数据根据结果进行相应的处理  
	        //var message =eval(result);
	        console.log(result);
	       console.log(result.msg);	
	        var result11 = result.result;
	        if(result11 == 0){
	        	alert("图片顺序不能重复");
	        	return false;
	        }else{
	        	
	         document.getElementById("myform").submit(); 
	        }
	       
	       
	        }
	    }); 
  }

  function isInteger(obj) {
	   return obj%1 === 0
	  }
	  isInteger(3) // true
	  isInteger(3.3) // false　 
  
  
</script>

</body>
</html>